package com.bbz.core.lambda.java8.Chapter_10_Optional;

import javax.swing.text.html.Option;
import java.util.Optional;

public class OptionalUtility {
    public static Optional<Integer> stringToInt(String s) {
        try {
            return Optional.of(Integer.parseInt(s));
        } catch (NumberFormatException e) {
            return Optional.empty();
        }
    }
    public static Optional<Double> stringToDouble(String s){
        try {
            return Optional.of(Double.parseDouble(s));
        }catch (NumberFormatException e){
            return Optional.empty();
        }
    }
}
